package com.yycwxt.modules.admin.Return;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yycwxt.domain.Return;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface ReturnMapper extends BaseMapper<Return> {

    @Select("""
            SELECT  account_date '账期'
                    ,shop_name '店铺名称'
                    ,SUM(CASE	WHEN subject_code = '1003-01-024-01' THEN cost END)'后台打款'
                    ,SUM(CASE WHEN subject_code = '1003-01-024-02' THEN	cost END)'微信打款'
                    ,SUM(CASE WHEN subject_code = '9001-01-001' THEN cost	END )'收入'
                    ,SUM(cost * subject_direction) '汇总'
                    FROM core_flows
                    WHERE (subject_code = '1003-01-024-01' or subject_code = '1003-01-024-02' or subject_code = '9001-01-001')
                    and account_date = #{account_date}
                    GROUP BY account_date,shop_name
            """)
    List<Map<String, Object>> getreturn(int zq);

    // 下载源文件
    @Select("select url from imp_files where remark like '%店铺打款%'")
    List<String> getDpdkUrl();
}
